import React from "react";
import http from "../../api/http";
import { NavBar } from "antd-mobile";
import { useNavigate } from "react-router-dom";
import { Form, Input, Button } from "antd-mobile";
import styles from "./index.module.css"
function Index() {
  const navigate = useNavigate();

  const onFinish=async(value)=>{
    const res=await http.post("/api/register",value)
    const {code}=res.data

    // console.log(data)
    if(code===200){
      navigate("/login")
    }
    
    
  }
  return (
    <div>
      <NavBar onBack={() => navigate("/")}></NavBar>
      <h2 className={styles.zhuc}>注册</h2>
      <Form
        layout="horizontal"
        onFinish={onFinish}
        footer={
          <Button block type="submit" color='danger' size="large" className={styles.btn}>
            提交
          </Button>
        }
      >
        <Form.Header></Form.Header>
        <Form.Item
          name="username"
          label=""
          rules={[{ required: true, message: "姓名不能为空" }]}
        >
          <Input  placeholder="请输入你的电子邮箱" />
        </Form.Item>
        <Form.Item
          name="password"
          label=""
          rules={[{ required: true, message: "密码不能为空" }]}
        >
          <Input  placeholder="请输入你的密码" />
        </Form.Item>
        <Form.Item
          name="password"
          label=""
          rules={[{ required: true, message: "密码不能为空" }]}
        >
          <Input  placeholder="在此输入你的密码" />
        </Form.Item>
      </Form>

      <span className={styles.wenbe}>已有账号 ？ <b onClick={()=>navigate("/login")}>立即登录</b></span>
    </div>
  );
}

export default Index;
